package com.example.demo.system.web;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.example.demo.annotation.ApiDesc;
import com.example.demo.entity.base.PageRequestBean;
import com.example.demo.entity.base.PageResponseBean;
import com.example.demo.entity.base.ResponseEntity;
import com.example.demo.entity.mybatisplus.SysConfigEntity;
import com.example.demo.system.service.impl.SystemConfigServiceImpl;

@RestController
@RequestMapping(value = "/systemconfig")
public class SystemConfigController {
	@Autowired
	private SystemConfigServiceImpl systemConfigServiceImpl;
	
	@ApiDesc("新增系统常用属性")
	@RequestMapping(value = "/addsysconfig",method = RequestMethod.POST)
	public Object addSysConfig(HttpServletRequest request,SysConfigEntity sysConfig,
							MultipartFile file) {
		
		ResponseEntity<String> ret = systemConfigServiceImpl.addSysConfig(sysConfig, file);
		
		return ret;
	}
	
	@ApiDesc("删除系统常用属性")
	@RequestMapping(value = "/deletesysconfigs")
	public Object deleteSysConfigs(HttpServletRequest request,@RequestParam String configIds){
		
		ResponseEntity<String> ret = systemConfigServiceImpl.deleteSysConfigs(configIds);
		
		return ret;
	}
	
	@ApiDesc("修改系统常用属性")
	@RequestMapping(value = "/updatesysconfig",method = RequestMethod.POST)
	public Object updateSysConfig(HttpServletRequest request,SysConfigEntity sysConfig,
							MultipartFile file) {
		
		ResponseEntity<String> ret = systemConfigServiceImpl.updateSysConfig(sysConfig, file);
		
		return ret;
	}
	
	@ApiDesc("分页查询系统常用属性")
	@RequestMapping(value = "/querysysconfigforpage",method = RequestMethod.POST)
	public Object querySysConfigForPage(HttpServletRequest request,@RequestBody PageRequestBean<SysConfigEntity> pagerequest) {
		
		ResponseEntity<PageResponseBean<SysConfigEntity>> ret = systemConfigServiceImpl.querySysConfigForPage(pagerequest);
		
		return ret;
	}
}
